﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Little_Tower_Defense.FieldTypes;

namespace Little_Tower_Defense
{
    class LevelLoader
    {
        static public List<Field> loadTextFile(string levelName)
        {
            string filename = @"Content\Level\" + levelName + ".txt";

            string[] lines = File.ReadAllLines(filename);

            List<Field> fields = new List<Field>();

            for (int row = 0; row < lines.Length; row++)
            {
                for (int column = 0; column < lines[row].Length; column++)
                {
                    switch (lines[row][column])
                    {
                        case '.': fields.Add(new Lawn(column, row)); break;
                        case '#': fields.Add(new Lane(column, row)); break;
                        case '~': fields.Add(new Water(column, row)); break;
                    }
                }
            }
            return fields;
        }
    }
}
